<?php session_start(); ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Parent Informer RCSHS - Pending Accounts Decisions</title>

<link rel=stylesheet href="../../../css-layouts/themes/defaulttheme.css" type="text/css">
<link rel=stylesheet href="../../../css-layouts/headlinks.css" type="text/css">
<link rel=stylesheet href="../../../css-layouts/imglinks.css" type="text/css">

<script type="text/javascript">

<!--

 function sendreq(todome) {
  if(todome=="approve") {
   if(confirm("Are you sure you want to approve the selected account request/s? Click OK to approve.")==true) {
    return true;
   }
   else {
    return false;
   }
  }
  else if(todome=="revoke") {
   if(confirm("Are you sure you want to revoke the selected account request/s? Click OK to revoke.")==true) {
    return true;
   }
   else {
    return false;
   }
  }
 }

//-->

</script>

</head>

<body>

<div id="mainhead"><br><br><br></div>

<?php 

 require_once("../../../sqlconfig.php");

 mysql_connect($server, $sqlusr, $sqlpass) or die(mysql_error());
 mysql_select_db($mydb) or die(mysql_error()); 

 //Checks if there is a login cookie
 if(isset($_COOKIE["parentinformerprcshs"]) || isset($_COOKIE["parentinformerurcshs"])) { 
  if(isset($_COOKIE["parentinformerprcshs"])) {
   $username = $_COOKIE["parentinformerprcshs"]; 
  }
  else {
   $_SESSION['theerrcode'] = 2;
   header("Location: ../../logerr_atmpt.php");
  }
  $pass = $_COOKIE["parentinformerurcshs"];
  $check = mysql_query("SELECT * FROM logtbl WHERE usernm = '".$username."'") or die(mysql_error());
  while($info=mysql_fetch_array($check)) {
   if ($pass!=$info['pwrnd']) {
    $_SESSION['theerrcode'] = 2;
    header("Location: ../../logerr_atmpt.php");
   }
   else {

    if($info['priv']!=1) {
     header("Location: ../../../");
     die();
    }

?>


<p class="leftnav">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Logged in as: <?php echo $_COOKIE["parentinformerprcshs"]; ?>
</p>

<p class="rightnav">

<b>Pending Accounts</b> || 
<a href="../../settings">Settings</a> || <a href="../../redirout.php">Logout</a>
</p>

<hr style="clear: both;"><br>

<center><span id="heading">REQUESTED ACCOUNTS</span></center>

<br><br>


<?php

    $queryandsortifany = "SELECT * FROM pendaccts";
    $showpendaccts = mysql_query($queryandsortifany);
    if(mysql_num_rows($showpendaccts)!=0) {

?>

<form method=post action="acctdec.php" id="acctdes">

<table class="tablerecd" align=center>
<tr>
<th></th>
<th>USERNAME&nbsp;<a href="?sort=desusr">SORT</a></th>
<th>PRIVILEGE&nbsp;<a href="?sort=despriv">SORT</a></th>
<th>MAIL ADDRESS</th>
<th>REASON/S</th>
<th>DATE REQUESTED&nbsp;<a href="?sort=dateadd">SORT</a></th>
</tr>

<?php
    
     while($getdata = mysql_fetch_array($showpendaccts)) {

      switch($getdata[2]) {
       case 1:
        $textpriv="Administrator/Adviser";
        break;
       case 2;
        $textpriv="Subject Teacher";
        break;
       case 3:
        $textpriv="Student";
        break;
      }
      echo "<tr>";
      echo "<td><input type='checkbox' name='sltdacct[]' id='sltdacct[]' value='".$getdata[0]."'></td>";
      echo "<td>".$getdata[0]."</td>";
      echo "<td>".$textpriv."</td>";
      echo "<td>".$getdata[3]."</td>";
      echo "<td>".$getdata[4]."</td>";
      echo "<td>".$getdata[5]."</td>";
      echo "</tr>";
     }

?>

</table>
<br>

<table align=center border=0>

<tr>
<td><input type="submit" value="REVOKE CHECKED" name="revoke" id="revoke" onclick="return sendreq('revoke');"></td>
<td><input type="submit" value="APPROVE CHECKED" name="approve" id="approve" onclick="return sendreq('approve');"></td>
</tr>

</table>

</form>

<?php

    }
    else {
     echo "<center>There are no pending accounts to approve or revoke.</center><br>";
    }

?>

<br>

<div class="footnav" align=center>

<hr>


<a href="../../../">Main Page</a> ||
<a href="#">Help</a> ||
<a href="../../../externalaffairs/links.php">Links</a> ||
<a href="#">About</a>
<br>

<span id="copyme">
&copy; 2011 Roosevelt College Science High School. All rights reserved.
</span>

</div>

</body>

<?php
   }
  }
 }
 else {
  header("Location: ../../");
 }

?>

</html>